class ConsultaDisciplina < Consulta
  def self.disciplinas(nome,orgao,page)
    @nome = nome
    @orgao = orgao
    @page = page
    @disciplinas ||= find_disciplinas
  end
  
  def self.find_disciplinas
    Disciplina.paginate :page => @page, :conditions => conditions,:per_page => 8
  end
  
  def self.nome_conditions
    ["nome like ?","%#{@nome}%"] unless @nome.blank?
  end
  
  def self.orgao_conditions
    ["orgao = ?",@orgao] unless @orgao.blank?
  end
end
